package operation;

import Book.Book;
import Book.Booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2022-05-23
 * Time:21:27
 */
public class AddOperation implements IOperation {

    @Override
    public void work(Booklist booklist) {
        System.out.println("增加图书");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入新增图书名字:");
        String name = scanner.nextLine();
        System.out.println("请输入新增图书作者:");
        String auther = scanner.nextLine();
        System.out.println("请输入新增图书价格:");
        double price = scanner.nextDouble();
        System.out.println("请输入新增图书类型:");
        String bookname = scanner.next();
        System.out.println("请输入新增图书数量");
        int bookQuantity = scanner.nextInt();
        int ret = booklist.getUsedSize();
        for (int i = 0; i < bookQuantity; i++) {
            Book book = new Book(name,auther,price,bookname);
            ret = ret + 1;
            booklist.setBooks(ret-1,book);
            booklist.setUsedSize(ret);
        }
        System.out.println("新增图书成功！");
    }
}
